/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package factoryTotal;


import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.geom.Rectangle;

/**
 *
 * @author wida46984148
 */
public class DisparoWida extends Disparo{

    Image balaW;

    public DisparoWida(float dany, Image image) {
        super(dany);
        this.balaW = image;

    }
/**
     * Canvia la posicio del projectil
     * @param pX
     * @param pY
     */
    @Override
    public void posicion(float posX, float posY) {
        super.posicion(posX, posY);
        super.s = new Rectangle(posX, posY, balaW.getWidth(), balaW.getHeight());
    }


    /**
     * Rederitza el projectil
     * @param gc
     * @param g
     */
    @Override
    public void render(GameContainer gc, Graphics g) {
        g.drawImage(balaW, pX, pY);
    }

    /**
     * Copia el projectil
     * @return projectil clonat
     */
    @Override
    public Disparo copiarDisparo() {
        return new DisparoWida(daño, balaW);
    }

    /**
     * Getter projectil clonat
     * @return projectil
     */
    public Disparo clonarDisparo() {
        Disparo p = (Disparo) copiarDisparo();
        p.posicion(pX, pY);
        return p;
    }

    /**
     * Genera impacte
     */
    public void impacto() {
        this.destruido = true;
    }

    public Image getBalaW() {
        return balaW;
    }

    @Override
    public void update(int delta){
        if(!(destruido)){
            if (pY <= 40){
                pY = 39;
                pX = 1300;
            } else {
                pY -= 10;
                s.setLocation(pX, pY);
            }
        } else {
            pY = 0;
            pX = 1300;
                s.setLocation(pX, pY);

        }
    }

}
